//
//  FCCustomerRelationRequestTool.m
//  AFNetworking
//
//  Created by 陈文斌 on 2019/3/22.
//

#import "FCCustomerRelationRequestTool.h"

@implementation FCCustomerRelationRequestTool
/**
 * 获取关系类型
 */
+ (NSString *)getCrmSupplyRelationTypeQuery{
    return @"query crmSupplyRelationTypes($args:CrmSupplyRelationTypeListArgs){\
        crmSupplyRelationTypes(args:$args){\
            items{\
                Id:id\
                name\
                manager:managerDto{\
                    Id:id\
                    Name:name\
                }\
                managerId\
                banModify\
            }\
            pageInfo {\
                total\
            }\
        }\
    }\
    ";
}

/**
 * 获取关系列表
 */
+ (NSString *)getRelationRequestsQuery{
    return @"\
    query crmSupplyRelations ($args: CrmSupplyRelationListArgs){\
        crmSupplyRelations(args:$args){\
            items{\
                Id:id\
                meId\
                relId\
                relCompanyName\
                rel{\
                    Name:name\
                    BrandName:brandName\
                    ResidentProvince:residentProvince\
                    ResidentCity:residentCity\
                }\
                status\
                relRelation{\
                    emps{\
                        employeeId\
                    }\
                }\
            }\
            pageInfo{\
                total\
            }\
        }\
    }\
    ";
}

/**
 * 添加上下游关系
 */
+ (NSString *)addRelationRequestsQuery{
    return @"\
    mutation addRelation($args:CrmSupplyRelationAddAouArgs!){\
        crmSupplyRelationAddAou(args:$args){\
            Id:id\
            meId\
            relId\
            relCompanyName\
            empCount\
            status\
        }\
    }\
    ";
}
/**
 * 获取关系详情
 */
+ (NSString *)getRelationDetailQuery{
    return @"\
    query crmSupplyRelationGet($args:CrmSupplyRelationGetArgs!){\
        crmSupplyRelationGet(args:$args){\
            Id:id\
            appId\
            meId\
            relId\
            relCompanyName\
            empCount\
            emps{\
                employeeId\
                relationId\
                employee{\
                    Id:id\
                    AccId:accId\
                    AccToken:accToken\
                    PortraitUrl:portraitUrl\
                    Name:name\
                    Tel:tel\
                    PhoneNumber:phoneNumber\
                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                    Email:email\
                    EmailImgEncodedData:emailImgEncodedData\
                    CompanyDepartment:companyDepartment{\
                        Id:id\
                        Name:name\
                    }\
                    CompanyId:companyId\
                    JobTitle:jobTitle\
                    Company:company{\
                        Id:id\
                        BrandName:brandName\
                    }\
                }\
            }\
            isAgreeSide\
            relOwnerMobile\
            status\
            statusInt\
            types{\
                Id:id\
                name\
                code\
            }\
            me{\
                Id:id\
                Name:name\
                BrandName:brandName\
                CustomMainBusiness:customMainBusiness\
                LogoUrl:logoUrl\
                Address:address\
                OwnerId:ownerId\
                OwnerIdentity:ownerIdentity{\
                    Id:id\
                    AccId:accId\
                    AccToken:accToken\
                    PhoneNumber:phoneNumber\
                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                }\
                Owner:owner{\
                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                }\
                ResidentArea:residentArea\
                ResidentCity:residentCity\
                ResidentCountry:residentCountry\
                ResidentProvince:residentProvince\
            }\
            rel{\
                Id:id\
                Name:name\
                BrandName:brandName\
                CustomMainBusiness:customMainBusiness\
                LogoUrl:logoUrl\
                Address:address\
                OwnerId:ownerId\
                OwnerIdentity:ownerIdentity{\
                    Id:id\
                    AccId:accId\
                    AccToken:accToken\
                    PhoneNumber:phoneNumber\
                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                }\
                Owner:owner{\
                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                }\
                ResidentArea:residentArea\
                ResidentCity:residentCity\
                ResidentCountry:residentCountry\
                ResidentProvince:residentProvince\
            }\
            relRelation{\
                Id:id\
                appId\
                meId\
                relId\
                relCompanyName\
                empCount\
                emps{\
                    employeeId\
                    relationId\
                    employee{\
                        Id:id\
                        AccId:accId\
                        AccToken:accToken\
                        PortraitUrl:portraitUrl\
                        Name:name\
                        Tel:tel\
                        PhoneNumber:phoneNumber\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                        Email:email\
                        EmailImgEncodedData:emailImgEncodedData\
                        CompanyDepartment:companyDepartment{\
                            Id:id\
                            Name:name\
                        }\
                        CompanyId:companyId\
                        JobTitle:jobTitle\
                        Company:company{\
                            Id:id\
                        }\
                    }\
                }\
                isAgreeSide\
                relOwnerMobile\
                status\
                statusInt\
                types{\
                    Id:id\
                    name\
                }\
                me{\
                    Id:id\
                    Name:name\
                    BrandName:brandName\
                    CustomMainBusiness:customMainBusiness\
                    LogoUrl:logoUrl\
                    Address:address\
                    OwnerIdentity:ownerIdentity{\
                        Id:id\
                        AccId:accId\
                        AccToken:accToken\
                        PhoneNumber:phoneNumber\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                    }\
                    Owner:owner{\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                    }\
                    ResidentArea:residentArea\
                    ResidentCity:residentCity\
                    ResidentCountry:residentCountry\
                    ResidentProvince:residentProvince\
                }\
                rel{\
                    Id:id\
                    Name:name\
                    BrandName:brandName\
                    CustomMainBusiness:customMainBusiness\
                    LogoUrl:logoUrl\
                    Address:address\
                    OwnerIdentity:ownerIdentity{\
                        Id:id\
                        AccId:accId\
                        AccToken:accToken\
                        PhoneNumber:phoneNumber\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                    }\
                    Owner:owner{\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                    }\
                    ResidentArea:residentArea\
                    ResidentCity:residentCity\
                    ResidentCountry:residentCountry\
                    ResidentProvince:residentProvince\
                }\
            }\
        }\
    }\
    ";
}
/**
 * 编辑关系信息
 */
+ (NSString *)editRelationQuery{
    return @"\
    mutation editRelation($args: CrmSupplyRelationAouArgs!){\
        crmSupplyRelationEditAou(args:$args){\
            Id:id\
            appId\
            meId\
            relId\
            relCompanyName\
            empCount\
                emps{\
                    employeeId\
                    relationId\
                    employee{\
                        Id:id\
                        AccId:accId\
                        AccToken:accToken\
                        PortraitUrl:portraitUrl\
                        Name:name\
                        Tel:tel\
                        PhoneNumber:phoneNumber\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                        Email:email\
                        EmailImgEncodedData:emailImgEncodedData\
                        CompanyDepartment:companyDepartment{\
                            Id:id\
                            Name:name\
                        }\
                        CompanyId:companyId\
                        JobTitle:jobTitle\
                        Company:company{\
                            Id:id\
                        }\
                    }\
                }\
            isAgreeSide\
            relOwnerMobile\
            status\
            statusInt\
            types{\
                Id:id\
                name\
            }\
            me{\
                Id:id\
                Name:name\
                BrandName:brandName\
                CustomMainBusiness:customMainBusiness\
                LogoUrl:logoUrl\
                Address:address\
                OwnerId:ownerId\
                OwnerIdentity:ownerIdentity{\
                    Id:id\
                    AccId:accId\
                    AccToken:accToken\
                    PhoneNumber:phoneNumber\
                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                }\
                Owner:owner{\
                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                }\
                ResidentArea:residentArea\
                ResidentCity:residentCity\
                ResidentCountry:residentCountry\
                ResidentProvince:residentProvince\
            }\
            rel{\
                Id:id\
                Name:name\
                BrandName:brandName\
                CustomMainBusiness:customMainBusiness\
                LogoUrl:logoUrl\
                Address:address\
                OwnerId:ownerId\
                OwnerIdentity:ownerIdentity{\
                    Id:id\
                    AccId:accId\
                    AccToken:accToken\
                    PhoneNumber:phoneNumber\
                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                }\
                Owner:owner{\
                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                }\
                ResidentArea:residentArea\
                ResidentCity:residentCity\
                ResidentCountry:residentCountry\
                ResidentProvince:residentProvince\
            }\
            relRelation{\
                Id:id\
                appId\
                meId\
                relId\
                relCompanyName\
                empCount\
                emps{\
                    employeeId\
                    relationId\
                    employee{\
                        Id:id\
                        AccId:accId\
                        AccToken:accToken\
                        PortraitUrl:portraitUrl\
                        Name:name\
                        Tel:tel\
                        PhoneNumber:phoneNumber\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                        Email:email\
                        EmailImgEncodedData:emailImgEncodedData\
                        CompanyDepartment:companyDepartment{\
                            Id:id\
                            Name:name\
                        }\
                        CompanyId:companyId\
                        JobTitle:jobTitle\
                        Company:company{\
                            Id:id\
                        }\
                    }\
                }\
                isAgreeSide\
                relOwnerMobile\
                status\
                statusInt\
                types{\
                    Id:id\
                    name\
                }\
                me{\
                    Id:id\
                    Name:name\
                    BrandName:brandName\
                    CustomMainBusiness:customMainBusiness\
                    LogoUrl:logoUrl\
                    Address:address\
                    OwnerIdentity:ownerIdentity{\
                        Id:id\
                        AccId:accId\
                        AccToken:accToken\
                        PhoneNumber:phoneNumber\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                    }\
                    Owner:owner{\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                    }\
                    ResidentArea:residentArea\
                    ResidentCity:residentCity\
                    ResidentCountry:residentCountry\
                    ResidentProvince:residentProvince\
                }\
                rel{\
                    Id:id\
                    Name:name\
                    BrandName:brandName\
                    CustomMainBusiness:customMainBusiness\
                    LogoUrl:logoUrl\
                    Address:address\
                    OwnerIdentity:ownerIdentity{\
                        Id:id\
                        AccId:accId\
                        AccToken:accToken\
                        PhoneNumber:phoneNumber\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                    }\
                    Owner:owner{\
                        PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                    }\
                    ResidentArea:residentArea\
                    ResidentCity:residentCity\
                    ResidentCountry:residentCountry\
                    ResidentProvince:residentProvince\
                }\
            }\
        }\
    }\
    ";
}
/**
 * 删除关系信息
 */
+ (NSString *)deleteRelationRequestQuery{
    return @"\
    mutation crmSupplyRelationDel($args:CrmSupplyRelationDelArgs!){\
        crmSupplyRelationDel(args:$args){\
            Id:id\
            status\
        }\
    }\
    ";
}
/**
 * 处理关系
 */
+ (NSString *)dealRelationRequestQuery{
    return @"\
    mutation dealRelation($args:CrmSupplyRelationDealAouArgs!){\
        crmSupplyRelationDealAou(args:$args){\
            Id:id\
            status\
            statusDesc\
        }\
    }\
    ";
}

/**
 * 工作组员工
 */
+ (NSString *)getWorkGroupEmployeeQuery{
    return @"\
    query ($ids: [ID], $skip: Int) {\
        crmSupplyRelationTypes(args: { ids: $ids, enable: true }) {\
            items {\
                Id:id\
                name\
                code\
                crmSupplyRelations(args: { take: 50, skip: $skip }) {\
                    pageInfo {\
                        currPage\
                        totalPage\
                    }\
                    items {\
                        relRelation{\
                            emps {\
                                employee {\
                                    Id:id\
                                    AccId:accId\
                                    AccToken:accToken\
                                    PortraitUrl:portraitUrl\
                                    Name:name\
                                    Tel:tel\
                                    PhoneNumber:phoneNumber\
                                    PhoneNumberImgEncodedData:phoneNumberImgEncodedData\
                                    Email:email\
                                    EmailImgEncodedData:emailImgEncodedData\
                                    CompanyDepartment:companyDepartment{\
                                        Id:id\
                                        Name:name\
                                    }\
                                    CompanyId:companyId\
                                    JobTitle:jobTitle\
                                }\
                            }\
                        }\
                    }\
                }\
            }\
        }\
    }\
    ";
}

/**
 * 根据全称和所有者电话获取企业
 */
+ (NSString *)getCompanyQuery{
    return @"\
    query companyByNamePhone($args:CompanyByNamePhoneArgs){\
        companyByNamePhone(args:$args){\
            id\
            legalPersonName\
            verifyStatus\
            owner{\
                phoneNumber\
            }\
        }\
    }\
    ";
}

/**
 * 添加或更新关系类型
 */
+ (NSString *)addOrUpdateRelationTypeQuery{
    return @"\
    mutation addType($args: CrmSupplyRelationTypeAouArgs!){\
        crmSupplyRelationTypeAou(args:$args){\
            Id:id\
            name\
        }\
    }\
    ";
}

/**
 * 删除关系类型
 */
+ (NSString *)deleteRelationTypeQuery{
    return @"\
    mutation crmSupplyRelationTypeDel($args: CrmSupplyRelationTypeDelArgs!){\
        crmSupplyRelationTypeDel(args: $args){\
            Id:id\
            name\
        }\
    }\
    ";
}

/**
 * 关系类型排序
 */
+ (NSString *)sortRelationTypeQuery{
    return @"\
    mutation sortType($args:CrmSupplyRelationTypeSortArgs!){\
        crmSupplyRelationTypeSort(args:$args){\
            id\
            name\
        }\
    }\
    ";
}

/**
 * 检测当前职员是否仅是类型负责人
 */
+ (NSString *)relationOnlyTypeManagerQuery{
    return @"\
    query crmSupplyRelationOnlyTypeManager($args: CrmSupplyRelationOnlyTypeManagerArgs!){\
        crmSupplyRelationOnlyTypeManager(args: $args) {\
            Id:id\
            companyDepartmentId\
        }\
    }\
    ";
}

@end
